/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uoc.tdp.client.proves;

import edu.uoc.tdp.beans.proves.EstatProva;
import java.io.Serializable;
import java.util.Vector;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author xmarti
 */

//TODO NOTES XMARTI
// LA FAIG SERVIR PER CARREGAR LES PREGUNTES A LA TAULA 
public class modelDadesPreguntaResposta extends AbstractTableModel implements Serializable{
 
    final String[] nomColumnes;
    final Object[][] dades;
    private EstatProva estat;
    
    public modelDadesPreguntaResposta(String[]Pcol, Object[][] Pdades, EstatProva pEstat){
        this.nomColumnes=Pcol;      
        this.dades=Pdades;
        this.estat=pEstat;
    }
        
    public int getRowCount() {
        return dades.length;
    }

    public int getColumnCount() {
           return nomColumnes.length;
    }
    public String getColumnName(int col) {
        return nomColumnes[col];
}

    public Object getValueAt(int rowIndex, int columnIndex) {
        return dades[rowIndex][columnIndex];

    }
    
    public Class getColumnClass(int c){
        return getValueAt(0,c).getClass();
    }
    
     public void setValueAt(Object value, int row, int col){        
        
         for(int i =1;i<=4;i++){
             if (i==col){
                 dades[row][i]=value;
             }
             else{
                 dades[row][i]=false;
             }
            fireTableCellUpdated(row,i);         
        }
         
        //fireTableCellUpdated(row,col);      
    }
    public boolean isCellEditable(int row,int col){        
        if(estat==null || estat==EstatProva.INICIAL ){
            return (col==0)?false:true;
        }
        return false;
    }
      
}
